package com.swallow.cloud.controller;

import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author: L.swallow
 * @Date: 2019/3/19 14:05
 */
@RequestMapping()
@Controller
public class LoginController {

    @RequestMapping("")
    public String index(){
        return "redirect:login";
    }
    /**
     * 判断用户是否已经登陆
     * @return
     */
    @GetMapping("login")
    public String login(){
        Object loginInfo= SecurityUtils.getSubject().getPrincipal();
        if(loginInfo!=null){
            return "sys/index";
        }
        return "sys/login";
    }

    @PostMapping("login")
    public String loginPost(){
        Object loginInfo= SecurityUtils.getSubject().getPrincipal();
        if(loginInfo!=null){
            return "sys/index";
        }
        return "sys/login";
    }
}
